<template>
  <section>
    <address-name v-if="control === 'address'"
                  :province="row.province"
                  :city="row.city"
                  :district="row.district"
                  :address="row.address"
                  class="tooltipSty" />
    <lat-lang v-else-if="control === 'lat'"
              :lat="row.lat"
              :lang="row.lon"
              class="tooltipSty" />
    <short-name v-else-if="control === 'short-name'"
                :id="row.carrierId"
                v-bind="$attrs"
                :name="row.abbr"
                class="tooltipSty"
                @handleSearch="handleSearch" />
    <tracking v-else-if="control === 'tracking'"
              :track-type="row.trackType"
              :device-code="row.deviceCode"
              class="tooltipSty" />
    <order-info v-else-if="control === 'order-info'"
                :row="row"
                class="tooltipSty" />
    <locus v-else-if="control === 'locus'"
           :row="row"
           :additional-info="row.additionalInfo"
           class="tooltipSty" />
    <array-column v-else-if="control === 'array'"
                  :value="row[preset.array]"
                  :filed-name="preset.filed"
                  class="tooltipSty" />
    <consignee-info v-else-if="control === 'consignee-info'"
                    :row="row"
                    :name="name"
                    class="tooltipSty" />
    <shipping-info v-else-if="control === 'shipping-info'"
                   :row="row"
                   :name="name"
                   class="tooltipSty" />
    <customer-info v-else-if="control === 'customer-info'"
                   :row="row"
                   class="tooltipSty" />
    <contact-info v-else-if="control === 'contact-info'"
                  :row="row"
                  class="tooltipSty" />
    <consigneer-info v-else-if="control === 'consigneer-info'"
                     :row="row"
                     class="tooltipSty" />
    <carrier-info v-else-if="control === 'carrier-info'"
                  :row="row"
                  class="tooltipSty" />
    <send-info v-else-if="control === 'send-info'"
               :row="row"
               class="tooltipSty" />
    <ShipmentSenderInfo v-else-if="control === 'shipment-sender-info'"
                        :row="row" />
    <link-detail v-else-if="control === 'link'"
                 :value="row[name]"
                 :row="row"
                 :url="preset.url"
                 :exception="preset.exception"
                 :combine="preset.combine"
                 :link-type="preset.linkType"
                 :params-data="preset.paramsData"
                 :transform="preset.transform"
                 :order-type="preset.orderType"
                 v-bind="$attrs" />
    <user-account v-else-if="control === 'user-account'"
                  :user-account="row.userAccount"
                  :tenant-alias="row.tenantAlias"
                  class="tooltipSty" />
    <boolean-escape v-else-if="control === 'boolean-escape'"
                    :name="name"
                    :row="row"
                    class="tooltipSty" />
    <way-bill-info v-else-if="control === 'way-bill-info'"
                   :row="row"
                   class="tooltipSty"></way-bill-info>
    <child-order-no v-else-if="control === 'child-order-no'"
                    :row="row"
                    class="tooltipSty"></child-order-no>
    <shipping-address v-else-if="control === 'shipping-address'"
                      :row="row"
                      class="tooltipSty"></shipping-address>
    <contract-company v-else-if="control === 'contract-company'"
                      :row="row"
                      :name="name"
                      class="tooltipSty" />
    <switch-company v-else-if="control === 'switch-company'"
                    :row="row"
                    :preset="preset"
                    class="tooltipSty" />
    <switch-entrust-bill v-else-if="control === 'switch-entrust-bill'"
                         :row="row"
                         :preset="preset"
                         class="tooltipSty" />
    <target-power v-else-if="control === 'target-power'"
                  :row="row"
                  class="tooltipSty" />
    <last-address v-else-if="control === 'last-address'"
                  :row="row"
                  :preset="preset"
                  class="tooltipSty" />
    <freight v-else-if="control === 'freight'"
             :value="row.totalPrice"
             :waybill-id="row.waybillId"
             :transform="preset && preset.transform"
             :row="row"
             v-bind="$attrs"
             class="tooltipSty" />
    <car-info v-else-if="control === 'car-info'"
              :row="row"
              class="tooltipSty" />
    <child-order-info v-else-if="control === 'child-order-info'"
                      :row="row"
                      v-bind="$attrs"
                      class="tooltipSty" />
    <split-child-order v-else-if="control === 'split-child-order'"
                       :row="row"
                       :value="row[name]"
                       :url="preset.url"
                       :link-type="preset.linkType"
                       :params-data="preset.paramsData"
                       :transform="preset.transform"
                       :order-type="preset.orderType"
                       v-bind="$attrs"
                       class="tooltipSty" />
    <validate-quote v-else-if="control === 'validate-quote'"
                    :value="row[name]"
                    :transform="preset && preset.transform"
                    :row="row" />
    <sign-time v-else-if="control === 'sign-time'"
               :row="row" />
    <SoonOverdue v-else-if="control === 'soon-overdue'"
                 :row="row"
                 v-bind="$attrs" />
    <!--
            {{control}}
            -->
    <bill-fee v-else-if="control === 'bill-fee'"
              :row="row"
              :filed-name="name"
              :quote-flag="row.quoteFlag"
              :obj-name="preset.objName"
              v-bind="$attrs"
              class="tooltipSty" />
    <object-column v-else-if="control === 'object-column'"
                   :row="row"
                   v-bind="$attrs"
                   :obj-name="preset.objName"
                   :filed-name="name" />
    <!--
              :objName="preset.objName"
              -->
    <!-- {{preset}} -->
    <!-- {{control}} -->
  </section>
</template>

<script>
import transform from "@/libs/transform.js";
import AddressName from "./Address";
import LatLang from "./LatLang";
import ShortName from "./ShortName";
import Tracking from "./Tracking";

import OrderInfo from "./OrderInfo";
import LinkDetail from "./LinkColumn.vue";
import ConsigneeInfo from "./ConsigneeInfo";
import CarrierInfo from "./CarrierInfo";
import Freight from "./Freight";
import CarInfo from "./CarInfo";
import SignTime from "./SignTime";
import ObjectColumn from "./ObjectColumn";
import ShippingInfo from "./ShippingInfo";
import ShipmentSenderInfo from "./ShipmentSenderInfo"
import SwitchCompany from "./SwitchCompany.vue";
import SwitchEntrustBill from "./SwitchEntrustBill.vue";
import LastAddress from "./LastAddress.vue";
import TargetPower from "./TargetPower.vue";
import ArrayColumn from "./ArrayColumn.vue";
import UserAccount from "./UserAccount.vue";
import CustomerInfo from "./CustomerInfo.vue";
import ContactInfo from "./ContactInfo.vue";
import ConsigneerInfo from "./ConsigneerInfo.vue";
import SendInfo from "./SendInfo.vue";
import BooleanEscape from "./BooleanEscape.vue";
import WayBillInfo from "./WayBillInfo";
import ChildOrderNo from "./ChildOrderNo.vue";
import ShippingAddress from "./ShippingAddress.vue";
import ContractCompany from "./ContractCompany.vue";
import ChildOrderInfo from "./ChildOrderInfo.vue";
import SplitChildOrder from "./SplitChildOrder.vue";
import ValidateQuote from "./ValidateQuote.vue";
import SoonOverdue from "./SoonOverdue.vue";
import BillFee from "./billFee/BillFee.vue";

export default {
  name: "ColumnConversion",
  components: {
    AddressName,
    LatLang,
    ShortName,
    Tracking,
    ArrayColumn,
    UserAccount,
    CustomerInfo,
    ContactInfo,
    ConsigneerInfo,
    OrderInfo,
    LinkDetail,
    ConsigneeInfo,
    ShippingInfo,
    ShipmentSenderInfo,
    SwitchCompany,
    SwitchEntrustBill,
    TargetPower,
    LastAddress,
    SendInfo,
    BooleanEscape,
    WayBillInfo,
    ChildOrderNo,
    CarrierInfo,
    ShippingAddress,
    ContractCompany,
    Freight,
    CarInfo,
    ChildOrderInfo,
    SplitChildOrder,
    ValidateQuote,
    SoonOverdue,
    SignTime,
    ObjectColumn,
    BillFee
  },
  inheritAttrs: true,
  props: {
    name: {
      type: String
    },
    control: {
      type: String
    },
    value: {
      type: Object
    },
    preset: {
      type: Object
    },
    transform: {
      type: Object
    }
  },
  computed: {
    row () {
      return transform(this.value, this.transform);
    }
  },
  methods: {
    handleSearch () {
      this.$emit("handleSearch");
    }
  }
};
</script>
<style lang="scss" scoped>
/**
 * 火狐tooltip不显示问题
 */
.tooltipSty {
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline;
}
</style>
